#include <wx/statbmp.h>
#include <wx/dc.h>
#include "wxsstaticbitmap.h"
#include "../wxsflags.h"

namespace {
  wxsRegisterItem<wxsStaticBitmap> Reg( _T( "StaticBitmap" ), _T( "统计图" ), wxsTWidget, _T( "标准" ), 80 );
  WXS_ST_BEGIN( wxsStaticBitmapStyles, _T( "wxSIMPLE_BORDER" ) )
  WXS_ST_CATEGORY( "wxStaticBitmap" )
  WXS_ST_DEFAULTS()
  WXS_ST_END()
  WXS_EV_BEGIN( wxsStaticBitmapEvents )
  WXS_EV_END()
}

wxsStaticBitmap::wxsStaticBitmap( wxsItemResData* Data ):
  wxsWidget( Data, &Reg.Info, wxsStaticBitmapEvents, wxsStaticBitmapStyles ) {}

void wxsStaticBitmap::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/statbmp.h>" ), GetInfo().ClassName, hfInPCH );
      wxsSizeData& SizeData = GetBaseProps()->m_Size;
      bool DontResize = SizeData.IsDefault;
      wxString SizeCodeStr = SizeData.GetSizeCode( GetCoderContext() );
      wxString BmpCode = Bitmap.IsEmpty() ? _T( "wxNullBitmap" ) : Bitmap.BuildCode( DontResize, SizeCodeStr, GetCoderContext(), _T( "wxART_OTHER" ) );
      Codef( _T( "%C(%W, %I, %s, %P, %S, %T, %N);\n" ), BmpCode.wx_str() );
      BuildSetupWindowCode();
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsStaticBitmap::OnBuildCreatingCode" ), GetLanguage() );
    }
  }
}


wxObject* wxsStaticBitmap::OnBuildPreview( wxWindow* Parent, long Flags ) {
  wxStaticBitmap* Preview = new wxStaticBitmap( Parent, GetId(), Bitmap.GetPreview( Size( Parent ) ), Pos( Parent ), Size( Parent ), Style() );
  return SetupWindow( Preview, Flags );
}

void wxsStaticBitmap::OnEnumWidgetProperties( M_Code_unused long Flags ) {
  WXS_BITMAP( wxsStaticBitmap, Bitmap, _T( "Bitmap" ), _T( "bitmap" ), _T( "wxART_OTHER" ) )
}

